package com.test.springboot3.springboot3testdemo1.controller;

import lombok.AllArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2024/8/5-下午7:02
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@AllArgsConstructor
@RestController
public class RedisController {
  private final StringRedisTemplate stringRedisTemplate;

  @GetMapping("/redis/set")
  public String set(@RequestParam("name") String name, @RequestParam("value") String value) {
    final ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue();
    valueOperations.set(name, value);
    return valueOperations.get(name);
  }
}
